#ifndef TEMPBUFFER_H
#define TEMPBUFFER_H

#include <QIODevice>

class QMutex;
class QueueBuffer : public QIODevice
{
    Q_OBJECT
public:
    QueueBuffer(qint64 size);
    ~QueueBuffer();
public:
    virtual bool open(OpenMode mode) override;
    virtual qint64 readData(char *data, qint64 maxlen) override;
    virtual qint64 writeData(const char *data, qint64 len) override;
private:
    QByteArray * m_buffer;
    QMutex * m_mutex;
    int m_size;
    int m_wpos;
    int m_rpos;
    int m_remain;
};

#endif // TEMPBUFFER_H
